Skip to content

[Feat] DD Trace - Add instrumentation for streaming chunks #11338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 2, 2025

Conversation

ishaan-jaff
Copy link
Contributor

@ishaan-jaff ishaan-jaff commented Jun 2, 2025

[Feat] DD Trace - Add instrumentation for streaming chunks

This PR adds DataDog trace instrumentation for streaming chunks and updates tests to verify the new tracing behavior.

Screenshot 2025-06-02 at 3 54 49 PM

After this PR

Screenshot 2025-06-02 at 3 56 47 PM

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature
✅ Test

Changes

Copy link

vercel bot commented Jun 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 2, 2025 11:49pm

@ishaan-jaff ishaan-jaff requested a review from Copilot June 2, 2025 23:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds DataDog trace instrumentation for streaming chunks and updates tests to verify the new tracing behavior.

  • Adds dd trace wrappers in the streaming generator (common_request_processing.py).
  • Adds decorator-based dd tracing for completion endpoints (main.py).
  • Updates tests and proxy configuration for new provider support and enhanced instrumentation.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_litellm/proxy/test_common_request_processing.py New tests verifying dd trace wrapping for streaming responses.
litellm/proxy/proxy_config.yaml Updated configuration to support the OpenAI model alongside anthropic.
litellm/proxy/common_request_processing.py Implements dd trace instrumentation within the streaming generator.
litellm/model_prices_and_context_window_backup.json Adds configuration for the embed-v4.0 model.
litellm/main.py Applies dd trace decorators to streaming and synchronous completion functions.
Comments suppressed due to low confidence (2)

tests/test_litellm/proxy/test_common_request_processing.py:291

  • It appears that MagicMock is being used without an explicit import. Add 'from unittest.mock import MagicMock' to ensure the tests run correctly.
mock_tracer = MagicMock()

tests/test_litellm/proxy/test_common_request_processing.py:346

  • It appears that MagicMock is being used without an explicit import in this test as well. Add 'from unittest.mock import MagicMock' to avoid NameError.
mock_tracer = MagicMock()

@ishaan-jaff ishaan-jaff merged commit 8a4b163 into main Jun 2, 2025
9 of 33 checks passed
ishaan-jaff added a commit that referenced this pull request Jun 3, 2025
* fix: add tracing for litellm.completion

* fix: NULL span add trace

* fix: add tracing for litellm.completion streaming

* fix: add tracing for litellm.completion streaming

* fix: use a constant for str
stefan-- pushed a commit to stefan--/litellm that referenced this pull request Jun 12, 2025
…1338)

* fix: add tracing for litellm.completion

* fix: NULL span add trace

* fix: add tracing for litellm.completion streaming

* fix: add tracing for litellm.completion streaming

* fix: use a constant for str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant